package com.rongke.web.api;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.rongke.commons.JsonResp;
import com.rongke.model.TdGjjBaseInfo;
import com.rongke.service.TdGjjBaseInfoService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

/**
 * @TdGjjBaseInfoController
 * @Controller
 * @version : Ver 1.0
 */
@RestController
@RequestMapping(value="/api/tdGjjBaseInfo")
@Transactional
@CrossOrigin
public class TdGjjBaseInfoController {
    private Logger log = Logger.getLogger(this.getClass());
    @Autowired
    private TdGjjBaseInfoService tdGjjBaseInfoService;

    /**
     * @添加
     * @param tdGjjBaseInfo
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/add", method = RequestMethod.POST)
    public JsonResp addTdGjjBaseInfo(@RequestBody TdGjjBaseInfo tdGjjBaseInfo){
        log.debug("添加");
        tdGjjBaseInfoService.insert(tdGjjBaseInfo);
        return JsonResp.ok(tdGjjBaseInfo);
    }

    /**
     * @修改
     * @param tdGjjBaseInfo
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/update", method = RequestMethod.POST)
    public JsonResp updateTdGjjBaseInfo(@RequestBody TdGjjBaseInfo tdGjjBaseInfo){
        log.debug("修改");
        tdGjjBaseInfoService.updateById(tdGjjBaseInfo);
        return JsonResp.ok(tdGjjBaseInfo);
    }
    /**
     * @根据id查找
     * @param id
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/selectOne", method = RequestMethod.GET)
    public JsonResp selectTdGjjBaseInfo(Long id){
        log.debug("查找");
        EntityWrapper ew = new EntityWrapper();
        ew.eq("user_id",id);
        TdGjjBaseInfo tdGjjBaseInfo = tdGjjBaseInfoService.selectOne(ew);
        return JsonResp.ok(tdGjjBaseInfo);
    }


}
